from remind.models import RemindModel
from django.contrib.auth.models import User
from .worker import send_worker
import datetime
from backend.models.login import GroupModel, UserInformationModel
from django.test import TestCase


class WorkserTestCase(TestCase):
    def setUp(self):
        user = User.objects.create_user(username="lisi", password="pass123456", email="12345678@qq.com",
                                        first_name="李四")
        information = UserInformationModel.objects.create(user=user, qq="1553770945")  # 替换成自己的测试QQ
        group = GroupModel.objects.create(name="test_group", owner=user)
        group.members.add(user)
        RemindModel.objects.create(owner=user, time=datetime.datetime.now(), notify_time=datetime.datetime.now(),
                                   event="吃饭", defer=8)
        remind = RemindModel.objects.get(defer=8)
        remind.groups.add(group)
        remind.save()
        self.remind = remind
        self.user = user
        self.group = group

    def test_worker(self):
        send_worker(self.remind)
